﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Axiom.Math;
using Engine.GuiDANCE.Components;
using Engine.GuiDANCE;

namespace Tools.Viewers.MeshViewer
{
    public partial class FormMeshViewer : Form
    {

        public FormMeshViewer()
        {
            InitializeComponent();
        }

        public GuiRenderBox RenderBox
        {
            get { return renderBox; }
            set { renderBox = value; }
        }

        public delegate void RenderTypeChangedEventHandler(MeshViewer.RenderTypes type, bool normalizeNormals);
        public event RenderTypeChangedEventHandler RenderTypeChanged;

        public delegate void BoundingBoxVisibilityChangedEventHandler(bool show);
        public event BoundingBoxVisibilityChangedEventHandler BoundingBoxVisibilityChanged;

        public delegate void GridsVisibilityChangedEventHandler(bool show);
        public event GridsVisibilityChangedEventHandler GridsVisibilityChanged;

        private void closeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void smoothShadedToolStripMenuItem_Click(object sender, EventArgs e)
        {
            RenderTypeChanged(MeshViewer.RenderTypes.Shaded, true);
            smoothShadedToolStripMenuItem.Checked = true;
            flatShadedToolStripMenuItem.Checked = false;
            wireframeToolStripMenuItem.Checked = false;
            pointCloudToolStripMenuItem.Checked = false;
        }

        private void flatShadedToolStripMenuItem_Click(object sender, EventArgs e)
        {
            RenderTypeChanged(MeshViewer.RenderTypes.Shaded, false);
            smoothShadedToolStripMenuItem.Checked = false;
            flatShadedToolStripMenuItem.Checked = true;
            wireframeToolStripMenuItem.Checked = false;
            pointCloudToolStripMenuItem.Checked = false;
        }

        private void wireframeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            RenderTypeChanged(MeshViewer.RenderTypes.Wireframe, false);
            smoothShadedToolStripMenuItem.Checked = false;
            flatShadedToolStripMenuItem.Checked = false;
            wireframeToolStripMenuItem.Checked = true;
            pointCloudToolStripMenuItem.Checked = false;
        }

        private void pointCloudToolStripMenuItem_Click(object sender, EventArgs e)
        {
            RenderTypeChanged(MeshViewer.RenderTypes.PointCloud, false);
            smoothShadedToolStripMenuItem.Checked = false;
            flatShadedToolStripMenuItem.Checked = false;
            wireframeToolStripMenuItem.Checked = false;
            pointCloudToolStripMenuItem.Checked = true;
        }

        private void boundingBoxToolStripMenuItem_Click(object sender, EventArgs e)
        {
            BoundingBoxVisibilityChanged(boundingBoxToolStripMenuItem.Checked);
        }

        private void gridsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GridsVisibilityChanged(gridsToolStripMenuItem.Checked);
        }

        private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormInfoAbout aboutForm = new FormInfoAbout();
            aboutForm.ShowDialog();
        }

        private void helpControlsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormInfoControls controlForm = new FormInfoControls();
            controlForm.ShowDialog();
        }
    }
}
